//
//  CommodityListCell.m
//  cityStar
//
//  Created by joyban on 14-12-24.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "CommodityListCell.h"

@implementation CommodityListCell

+(CGFloat)heightOfTableCell
{
    return 105;
}

-(void)configWithCommidity:(GetGoodsQuery *)commidity
{
    [self.heardImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://api.icszx.com/image/c/id/%@/w/130/h/87/m/0",commidity.image]] placeholderImage:[UIImage imageNamed:@"商品列表_img"]];
    self.heardImage.contentMode =  UIViewContentModeCenter;
    self.commodity = commidity;
    self.contentLabel.text = [NSString stringWithFormat:@"%@",commidity.name];
    if (commidity.special_price) {
        self.NewPriceLabel.text = [NSString stringWithFormat:@"￥%@",commidity.special_price];
    }else{
    self.NewPriceLabel.text = [NSString stringWithFormat:@"￥%@",commidity.now_price];
    }
//    self.OldPriceLabel.text = [NSString stringWithFormat:@"￥%@",commidity.market_price];
    
    NSString *oldPrice = [NSString stringWithFormat:@"￥%@",commidity.market_price];
    NSUInteger length = [oldPrice length];
    
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:oldPrice];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, length)];
    [attri addAttribute:NSStrikethroughColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0, length)];
    [self.OldPriceLabel setAttributedText:attri];
    
    if (commidity.comments) {
        self.CommentLabel.text = [NSString stringWithFormat:@"%@评",commidity.comments];
    }else{
    self.CommentLabel.text = [NSString stringWithFormat:@"%@评",commidity.commnets];
    }
}

-(IBAction)addShopCart_Touch:(id)sender
{
    if ([self.delegate respondsToSelector:@selector(addShopCartWithCommidityID:)]) {
        [self.delegate addShopCartWithCommidityID:[NSString stringWithFormat:@"%@",self.commodity.objectId]];
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
